package com.qhg.saas_server.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qhg.saas_server.mapper.WarehouseMapper;
import com.qhg.saas_server.pojo.Warehouse;
import com.qhg.saas_server.pojo.dto.WarehouseInfoDto;
import com.qhg.saas_server.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WarehouseServiceImpl implements WarehouseService {

    @Autowired
    WarehouseMapper warehouseMapper;
    @Override
    public PageInfo SelectWarehouse(Integer pageNum, Integer pageSize, String wareName, String wareComploName) {
        PageHelper.startPage(pageNum,pageSize);
        List<WarehouseInfoDto> warehouseInfoDtos = warehouseMapper.SelectWarehouse(wareName, wareComploName);
        PageInfo<WarehouseInfoDto> pageInfo =new PageInfo<>(warehouseInfoDtos);
        return pageInfo;
    }

    @Override
    public WarehouseInfoDto SelectById(Integer wareId) {
        return warehouseMapper.SelectByIsd(wareId);
    }

    @Override
    public void InsertWarehouse(Warehouse warehouse) {
        warehouseMapper.InsertWarehouse(warehouse);
    }

    @Override
    public void UpdateStatus(Integer wareStatus, Integer wareId) {
        warehouseMapper.UpdateStatus(wareStatus,wareId);
    }

    @Override
    public void UpdateWarehouse(Warehouse warehouse) {
        warehouseMapper.UpdateWarehouse(warehouse);
    }

    @Override
    public void DeleteById(Integer wareId) {
        warehouseMapper.DeleteById(wareId);
    }
}
